const Controller = require('../core/base_controller');


class UserController extends Controller {
  async getid() {
    const { ctx, ctx: { service, customBody }, app, app: { mysql } } = this;
    const ACCESS_TOKEN = await this.get_access_token()
    var url = `https://api.weixin.qq.com/tcb/databasecollectionget?access_token=${ACCESS_TOKEN}`
    const result = await ctx.curl(url, {
      // 必须指定 method
      method: 'POST',
      // 通过 contentType 告诉 HttpClient 以 JSON 格式发送
      contentType: 'json',
      data: {
        env: 'gsytest-1-f8fcc3',
        access_token: ACCESS_TOKEN,
      },
      // 明确告诉 HttpClient 以 JSON 格式处理返回的响应 body
      dataType: 'json',
    });
    // var jsonstring = result.data.toString()
    // var jsonobject = JSON.parse(jsonstring)
    console.log(result.data)

    // 获取参数然后保存
    // var { openid = 'opHTu0BFAOqiHVyDhcIX3mEesfgk' } = customBody
    // var istrue = await service.user.find(openid)
    // ctx.body = istrue;
    // var userInfo = await mysql.get('wx_user', { openid })
    // ctx.body = userInfo;
  }
  async userInfo() {
    const { ctx } = this;

  }

}

module.exports = UserController;